<?php
//跳转类
class Redirect {
    static private $instance = null;       //用于存放实例化的对象
    private $tpl = null;
    private $js = '';
    //公共静态方法获取实例化的对象
    static public function getInstance(TPL &$tpl = null) {
        if(!(self::$instance instanceof self)){
            self::$instance = new self();
            self::$instance->tpl = $tpl;
        }
        return self::$instance;
    }
    //私有克隆
    private function __clone() {
    }
    private function __construct() {
    }
    //成功跳转
    public function success($url,$info = '') {
        if(!empty($info)){
            $this->tpl->assign('message',$info);
            $this->tpl->assign('url',$url);
            $this->tpl->display(SMARTY_ADMIN.'public/'.'success.tpl');
        } else {
            header('location:'.$url);
        }
        die();
    }
    //失败返回
    public function failed($info) {
        $this->tpl->assign('message',$info);
        $this->tpl->assign('prev',Tool::getPrevPage());
        $this->tpl->display(SMARTY_ADMIN.'public/'.'error.tpl');
        die();
    }
}